package com.wlsk.license.common.enums;

import lombok.Getter;

@Getter
public enum RetEnum {
    // 可自己添加常用状态
    SUCCESS(1, "成功"),
    FAILED(0, "失败"),
    PARAM_ERROR(400, "参数异常"),

    /* 订单相关 **/
    ORDER_STATUS_ERROR(700, "订单状态异常"),
    PRODUCT_NOT_EXIST(701, "产品不存在"),
    VEHICLE_MODEL_NOT_EXIST(702, "车型不存在")
    ;
    private Integer code;
    private String msg;

    RetEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static boolean isSuccess(Integer code) {
        if (code == null) {
            return false;
        }
        return RetEnum.SUCCESS.getCode().equals(code);
    }

    public static boolean isFailed(Integer code) {
        return !RetEnum.isSuccess(code);
    }
}